<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <link rel="icon" type="image/svg+xml" href="/src/favicon.svg" />
    <meta
      name="viewport"
      content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover"
    />
    <!-- 禁止横屏 -->
    <meta name="screen-orientation" content="portrait" />
    <title>Vite App</title>
    <style>
      #container {display: none} 
    </style>
    <script>
      var ms = /Html5Plus\/.+\s\(.*(Immersed\/(\d+\.?\d*).*)\)/gi.exec(
        navigator.userAgent
      );
      // 当前环境为沉浸式状态栏模式
      if (ms && ms.length >= 3) {
        var immersed = parseFloat(ms[2]) || 0;
        // 获取状态栏的高度 }
        var t = document.getElementById('root');
        if (t) {
          t.style.paddingTop = immersed + 'px';
        }
      }
    </script>
  </head>
  <body>
    <!-- ios 下 viewport-fit=cover 设置为全屏幕，然后使用安全区域 -->
    <div id="root" class="root-wrap"></div>
    <!-- 地图容器 -->
    <div id="container" ></div> 
    <script type="module" src="/src/main.tsx"></script>
    <!-- defer 页面渲染完之后 -->
    <script src="https://webapi.amap.com/maps?v=2.0&key=58fe48fd780369a6a1fc85456dd5ece1&callback=onLoad" defer></script>
    <script type="text/javascript" >
      window.onLoad  = function() {
        var map = new AMap.Map('container', {
          zoom:12,
          resizeEnable: true,
        })
        window.currentCity = "北京";
        map.plugin('AMap.Geolocation', function() {
          var geolocation = new AMap.Geolocation({
            enableHighAccuracy: true, 
            timeout: 10000 
          });
          geolocation.getCityInfo(getCity)
        });
        function getCity(status, result) {
          if (status !== 'complete') {
            console.log('定位失败');
            //  showToast();
          } else {
            window.currentCity=result.city.slice(0,2)
            // console.log(12,result.city);
          }
        }
      }
      // var url = '';
      // var jsapi = document.createElement('script');
      // jsapi.charset = 'utf-8';
      // jsapi.src = url;
      // document.body.appendChild(jsapi);
      // 地图初始化应该在地图容器div已经添加到DOM树之后
    </script>
  </body>
</html>
